package cn.com.idmy.base.exception;

import cn.com.idmy.base.DefaultError;
import cn.com.idmy.base.Err;
import org.dromara.hutool.core.text.StrUtil;
import org.jetbrains.annotations.Nullable;

public class UnauthorizedException extends ErrorCodeException {
    public UnauthorizedException() {
        super(DefaultError.UNAUTHORIZED);
    }

    public UnauthorizedException(String message, Object... params) {
        this(DefaultError.UNAUTHORIZED.code(), message, params);
    }

    public UnauthorizedException(int code, String message, Object... params) {
        super(new Err() {
            @Override
            public int code() {
                return code;
            }

            @Override
            public @Nullable String msg() {
                return StrUtil.format(message, params);
            }
        });
    }
}
